#include<bits/stdc++.h>
using namespace std;
long long n,m,w,ww;
int main()
{
	freopen("dfs.in","r",stdin);
	freopen("dfs.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;++i)
	{
		cin>>w;
		for(int j=1;j<=w;++j)
			cin>>ww;
	}
	for(int i=1;i<=m;++i)
		cin>>w,cout<<1<<'\n';
 } 
